/**
 * MetaFileGenerator.java : [com.shift.converter.editors] Created on 2009. 5. 5.
 * 
 * Copyright (c) 2000-2008 Shift Information & Communication Co.
 * 5F, Seongsu Venture town, 231-1, Seongsu2-Ga Seongdong-Gu, Seoul, Korea 133-826
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Shift Information & Communication Co. ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use 
 * it only in accordance with the terms of the license agreement you 
 * entered into with Shift Information & Communication.
 */
package com.shift.converter.editors;

import groovy.text.SimpleTemplateEngine;
import groovy.text.Template;
import groovy.text.TemplateEngine;

import java.io.Reader;
import java.util.HashMap;
import java.util.Map;

import com.shift.converter.beans.MapConfigBean;

public class MetaFileGenerator {
	private TemplateEngine engine;

	public MetaFileGenerator() {
		engine = new SimpleTemplateEngine();
	}

	private String build(Template templete, Map bobj) throws Exception {
		String result = templete.make(bobj).toString();
		return result;
	}

	public String build(Reader reader, MapConfigBean mapConfigBean)
			throws Exception {
		Map bobj = new HashMap();
//		bobj.put("id", serviceGroupBean.getId());
//		bobj.put("description", serviceGroupBean.getData());
//		bobj.put("version", serviceGroupBean.version);
//		bobj.put("services", serviceGroupBean.getServiceBeans());
//		bobj.put("actionConfig", serviceGroupBean.actionConfig);
		return build(reader, bobj);
	}

	public String build(Reader reader, Map bobj) throws Exception {
		String result = null;
		try {
			Template templete = engine.createTemplate(reader);
			result = build(templete, bobj);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
}
